<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateActivity extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $prefix = \Config::get('database.connections.mysql.prefix');
        $sql = <<<SQL
        create table {$prefix}activity
        (
          id int(10) unsigned not null auto_increment
            primary key,
          title varchar(255) not null ,
          img varchar(255) not null ,
          cost int default 0 comment '费用',
          cost_info text default null comment '费用说明',
          limit_of_number int default 0 comment '人数限制',
          route varchar(255) not null comment '路线', 
          route_info text not null comment '路线说明',
          type varchar(20) not null comment '类型：1短线，2长线，3定制',
          strength int default 0 comment '活动强度',
          view_index int default 0 comment '风景指数',
          collection_time timestamp not null comment '集合时间',
          collection_place varchar(255) not null comment '集合地点',
          sort smallint default 0,
          on_line_time timestamp null default null comment '上线时间',
          off_line_time timestamp null default null  comment '下线时间',
          created_at timestamp null default null,
          updated_at timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
          deleted_at timestamp null default null
        );
SQL;
        if (!DB::statement($sql)) {
            throw new \Exception("failed on execute SQL: [{$sql}]");
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        throw new \Exception('downgrade is forbidden');
    }
}
